#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > ccsdr12_n2_sym_exc.info <<'%EOF%'
   ccsdr12_n2_sym_exc
   -------------
   Molecule:         N2
   Wave Function:    CCSD(R12) / cc-pVDZ
   Test Purpose:     - CCSD(R12) excitation energies exploiting symmetry
                     - test .R12ORB
                     - non-direct mode
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > ccsdr12_n2_sym_exc.mol <<'%EOF%'
BASIS
cc-pVDZ aug-cc-pVTZ
N2

    2  0 3  X  Y  Z  0.10D-14
 1      7.    1
N        0.0000000000000     0.0000000000000     1.0371572000000       *
 2      7.    1
N        0.0000000000000     0.0000000000000     1.0371572000000       *
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > ccsdr12_n2_sym_exc.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTION
*MOLBAS
.R12AUX
**INTEGRALS
.R12
**WAVE FUNCTIONS
.CC
*SCF INPUT
.THRESHOLD
 1D-10
*ORBITALS
.MOSTART
 H1DIAG
.R12ORB
 0 0 0 0 0 1 1 0
*CC INPUT
.CCSD
.PRINT
 3
.FREEZE
 2 0
.THRENR
 1.0D-12
.MAX IT
 100
*CCEXCI
.THREXC
 1.0D-08
.NCCEXC
 2 2 2 2 2 2 2 2
*R12 INP
.NO HYB
.CC2
 1B
**END OF DALTON INPUT
%EOF%

#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >ccsdr12_n2_sym_exc.check
cat >>ccsdr12_n2_sym_exc.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#
#           Total SCF   energy:                  -108.9541307667
#           Total MP2-R12/B energy:              -109.2968962535
#           Total CCSD(R12)/B energy:            -109.2902171301
#
#
#+=============================================================================+
#|  sym. | Exci.  |        CCSD(R12)/ Excitation energies            | ||T1||  |
#|(spin, |        +------------------------------------------------------------+
#| spat) |        |     Hartree    |       eV.      |     cm-1       |    %    |
#+=============================================================================+
#| ^1Ag  |    1   |     0.7530229  |      20.49079  |    165269.419  |   1.22  |
#| ^1Ag  |    2   |     0.8272600  |      22.51089  |    181562.578  |   4.54  |
#+-----------------------------------------------------------------------------+
#| ^1B3u |    1   |     0.5141292  |      13.99017  |    112838.311  |  84.91  |
#| ^1B3u |    2   |     0.8286736  |      22.54935  |    181872.830  |   9.05  |
#+-----------------------------------------------------------------------------+
#| ^1B2u |    1   |     0.5141292  |      13.99017  |    112838.311  |  84.91  |
#| ^1B2u |    2   |     0.8286736  |      22.54935  |    181872.830  |   9.05  |
#+-----------------------------------------------------------------------------+
#| ^1B1g |    1   |     0.8081773  |      21.99162  |    177374.422  |   0.27  |
#| ^1B1g |    2   |     0.9054780  |      24.63931  |    198729.442  |   2.53  |
#+-----------------------------------------------------------------------------+
#| ^1B1u |    1   |     0.3968880  |      10.79987  |     87106.857  |  96.86  |
#| ^1B1u |    2   |     0.6235170  |      16.96676  |    136846.172  |  97.22  |
#+-----------------------------------------------------------------------------+
#| ^1B2g |    1   |     0.3539567  |       9.63165  |     77684.522  |  94.32  |
#| ^1B2g |    2   |     0.8718340  |      23.72381  |    191345.449  |  88.95  |
#+-----------------------------------------------------------------------------+
#| ^1B3g |    1   |     0.3539567  |       9.63165  |     77684.522  |  94.32  |
#| ^1B3g |    2   |     0.8718340  |      23.72381  |    191345.449  |  88.95  |
#+-----------------------------------------------------------------------------+
#| ^1Au  |    1   |     0.3819817  |      10.39425  |     83835.301  |  98.02  |
#| ^1Au  |    2   |     0.3968880  |      10.79987  |     87106.857  |  96.86  |
#+=============================================================================+

#

CRIT1=`$GREP "Total MP2-R12/B energy: *-109\.296896253" $log | wc -l`
TEST[1]=`expr   $CRIT1`
CTRL[1]=2
ERROR[1]="MP2-R12/B ENERGY NOT CORRECT"
CRIT2=`$GREP "Total CCSD\(R12\)/B energy: *-109\.290217130" $log | wc -l`
TEST[2]=`expr   $CRIT2`
CTRL[2]=2
ERROR[2]="CCSD(R12)/B ENERGY NOT CORRECT"
#
CRIT3=`$GREP " 9.63165  \|" $log | wc -l`
TEST[3]=`expr   $CRIT3`
CTRL[3]=2
CRIT4=`$GREP " 10.39425  \|" $log | wc -l`
TEST[4]=`expr   $CRIT4`
CTRL[4]=1
CRIT5=`$GREP " 10.79987  \|" $log | wc -l`
TEST[5]=`expr   $CRIT5`
CTRL[5]=2
CRIT6=`$GREP " 13.99017  \|" $log | wc -l`
TEST[6]=`expr   $CRIT6`
CTRL[6]=2
CRIT7=`$GREP " 16.96676  \|" $log | wc -l`
TEST[7]=`expr   $CRIT7`
CTRL[7]=1
CRIT8=`$GREP " 20.49079  \|" $log | wc -l`
TEST[8]=`expr   $CRIT8`
CTRL[8]=1
CRIT9=`$GREP " 21.99162  \|" $log | wc -l`
TEST[9]=`expr   $CRIT9`
CTRL[9]=1
CRIT10=`$GREP " 22.54935  \|" $log | wc -l`
TEST[10]=`expr   $CRIT10`
CTRL[10]=2
CRIT11=`$GREP " 23.72381  \|" $log | wc -l`
TEST[11]=`expr   $CRIT11`
CTRL[11]=2
CRIT12=`$GREP " 24.63931  \|" $log | wc -l`
TEST[12]=`expr   $CRIT12`
CTRL[12]=1
CRIT13=`$GREP " 22.51089  \|" $log | wc -l`
TEST[13]=`expr   $CRIT13`
CTRL[13]=1
TEST[13]=`expr $CRIT3 + $CRIT4 + $CRIT5 + $CRIT6 + $CRIT7 + $CRIT8 + $CRIT9 \
         + $CRIT10 + $CRIT11 + $CRIT12 + $CRIT13`
CTRL[13]=16
ERROR[13]="CCSD(R12)/B EXCITATION ENERGIES NOT CORRECT"

PASSED=1
for i in 1 2 12
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

%EOF%
#######################################################################
